/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ondrej
 */
@Entity
@Table(name = "file")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "File.findAll", query = "SELECT f FROM File f"),
    @NamedQuery(name = "File.findById", query = "SELECT f FROM File f WHERE f.id = :id"),
    @NamedQuery(name = "File.findByPageCount", query = "SELECT f FROM File f WHERE f.pageCount = :pageCount"),
    @NamedQuery(name = "File.findByDescription", query = "SELECT f FROM File f WHERE f.description = :description")})
public class File implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "page_count")
    private Integer pageCount;
    @Size(max = 200)
    @Column(name = "description")
    private String description;
    @OneToMany(mappedBy = "fILEid")
    private Collection<FileShare> fileShareCollection;
    @OneToMany(mappedBy = "fILEid")
    private Collection<Plotting> plottingCollection;
    @JoinColumn(name = "PROJECT_id", referencedColumnName = "id")
    @ManyToOne
    private Project pROJECTid;

    public File() {
    }

    public File(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getPageCount() {
        return pageCount;
    }

    public void setPageCount(Integer pageCount) {
        this.pageCount = pageCount;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @XmlTransient
    public Collection<FileShare> getFileShareCollection() {
        return fileShareCollection;
    }

    public void setFileShareCollection(Collection<FileShare> fileShareCollection) {
        this.fileShareCollection = fileShareCollection;
    }

    @XmlTransient
    public Collection<Plotting> getPlottingCollection() {
        return plottingCollection;
    }

    public void setPlottingCollection(Collection<Plotting> plottingCollection) {
        this.plottingCollection = plottingCollection;
    }

    public Project getPROJECTid() {
        return pROJECTid;
    }

    public void setPROJECTid(Project pROJECTid) {
        this.pROJECTid = pROJECTid;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof File)) {
            return false;
        }
        File other = (File) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.entities.File[ id=" + id + " ]";
    }
    
}
